package com.platform.boot.security;

import lombok.Data;
import org.springframework.web.server.WebSession;

import java.io.Serializable;

/**
 * @author <a href="https://github.com/vnobo">Alex bob</a>
 */
@Data(staticConstructor = "of")
public class AuthenticationToken implements Serializable {

    private final String token;
    private final Long expires;
    private final Long lastAccessTime;

    public static AuthenticationToken build(WebSession session) {
        return AuthenticationToken.of(session.getId(),
                session.getMaxIdleTime().getSeconds(),
                session.getLastAccessTime().getEpochSecond());
    }
}